package com.jt.controller;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestCallable {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        FutureTask<String> futureTask=new FutureTask<>(myCallable);
        Thread thread=new Thread( futureTask);
        thread.start();
        String s = futureTask.get();
        System.out.println(s);
    }

    static class MyCallable implements Callable<String> {
        @Override
        public String call() throws Exception {
            for (int i = 0; i < 5; i++) {
                System.out.println("线程开始》》》》》》》》》》》》》》》》");
            }
            return "返回数据111";
        }
    }

}
